
const request = window.axios

// 获取权限列表
export function getRightsList (type) {
  return request({
    url: 'rights/' + type
  })
}

// 获取角色列表
export function getRolesList () {
  return request({
    url: 'roles/'
  })
}

// 删除角色权限
export function delRoleRights (roleId, rightId) {
  return request({
    url: `roles/${roleId}/rights/${rightId}`,
    method: 'delete'
  })
}

// 添加角色
export function addRole (data) {
  return request({
    url: 'roles',
    method: 'post',
    data
  })
}

// 根据id查询角色
export function searchRole (id) {
  return request({
    url: 'roles/' + id
  })
}

// 修改角色
export function setRole (id, data) {
  return request({
    url: 'roles/' + id,
    method: 'put',
    data
  })
}

// 删除角色
export function delRole (id) {
  return request({
    url: 'roles/' + id,
    method: 'delete'
  })
}

// 添加授权
export function allotRights (id, rids) {
  return request({
    url: 'roles/' + id + '/rights',
    method: 'post',
    data: { rids }
  })
}
